<template>
  <div class="search">
    <f-drawer ref="detailDrawer" :title="drawerTitle" width="90%" @submit="handleSubmit" @visibleChange="visibleChange" :showFooter="false">
      <a-tabs @tabClick="tabClick" :defaultActiveKey="current" v-model="current">
        <a-tab-pane tab="材料申请详情" key="details_list">
           <applicationdetail ref="details_list" v-if="drawerVisible"  :detailsParams="detailsParams" :projectStatus="projectStatus"></applicationdetail>
        </a-tab-pane>
      </a-tabs>
    </f-drawer>
  </div>
</template>
<script>
    import applicationdetail from './applicationdetail'
    import api from './js/api'
    export default {
      name: 'detailDrawer',
      components: { applicationdetail },
      props: {},
      data() {
        return {
          api:  Object.assign(api, this.api),
          refs: this.$refs,
          drawerVisible: false,
          detailsParams: {},
          formData: {},
          projectStatus: '',
          current: 'details_list'
        }
      },
      methods: {
        showDrawer(data) {
          this.detailsParams.projectId = data.projectId
          this.detailsParams.version = data.bigVersion
          this.http.get(this, {
            url: this.api.project.projectStatus,
            data: {
              projectId: data.projectId
            },
            success: function (me, data) {
              me.projectStatus = data
            }
          })
          this.refs['detailDrawer'].show()
          this.tabClick('details_list')
        },
        handleSubmit(callback) {
          this.refs[this.current].handleSubmit(callback)
        },
        visibleChange(drawerVisible) {
          this.drawerVisible = drawerVisible
        },
        tabClick(name) {
          this.current = name
          if (this.current === 'details_list') {
            this.title = '材料申请详情'
          }
        }
      },
      computed: {
        drawerTitle: function () {
          return this.title
        }
      },
      created() {
      }
    }

</script>

<style scoped>

</style>